package api

import (
	"github.com/gin-gonic/gin"
	"shopping_08_20/api/handler"
	"shopping_08_20/api/middleware"
)

func LoadRouter(r *gin.Engine) {

	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			//注册
			user.POST("register", handler.RegisterUser)
			//登陆
			user.POST("login", handler.LoginUser)
		}

		auth := api.Group("/auth")
		{
			//验证
			auth.Use(middleware.Auth())
			//添加评论
			auth.POST("addComment", handler.AddComment)
			//查看商品下评论
			auth.GET("findShopComment", handler.FindShopComment)
			//修改评论
			auth.POST("updateComment", handler.UpdateComment)
			//删除评论
			auth.POST("deleteComment", handler.DeleteComment)

		}

		shop := api.Group("/shop")
		{
			//添加商品
			shop.POST("add", handler.AddShop)
			//ID查询商品
			shop.GET("IdGet", handler.IdGetShop)
			//商品信息更新
			shop.POST("update", handler.UpdateShop)
			//商品条目删除
			shop.POST("delete", handler.DeleteShop)
		}
	}

}
